#include "widget.h"
#include "ui_widget.h"

int factorial(int n) {
    int ret = 1;
    for (int i = 1; i <= n; i++) {
        ret *= i;
    }
    return ret;
}

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QFuture<int> future = QtConcurrent::run(factorial, 10);

    // 等待任务完成，并获取结果
    int ret = future.result();
    qDebug() << "ret == " << ret;
}

Widget::~Widget()
{
    delete ui;
}

//int Widget::factorial(int n)
//{
//    int ret = 1;
//    for (int i = 1; i <= n; i++) {
//        ret *= i;
//    }
//    return ret;
//}

